package com.itfreer.form.dao.metadata;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

import org.springframework.beans.BeanUtils;

import com.itfreer.form.api.JdbcBaseEntity;
import com.itfreer.form.entity.metadata.MetadataEntity;

/**
 * 类功能说明 定义表结构实体
 */
@Entity(name = "form_metadata")
@Table(indexes = { 
        @Index(name="f_d_dicname", columnList="s_mid") })
public class JdbcMetadataEntity implements JdbcBaseEntity<MetadataEntity>, Serializable {

	protected static final long serialVersionUID = -7828937287884523173L;

	/**
	 * 外建，元数据ID值
	 */
	@Column(name = "s_mid", nullable = true)
	protected String mid;
	
	/**
	 * 元数据信息ID
	 * 主键
	 */
	@Id
	@Column(name = "id", length = 50, nullable = false)
	protected String id;

	/**
	 * 排序值
	 */
	@Column(name = "i_order", nullable = true)
	protected Integer order;
	
	/**
	 * 字段名称
	 */
	@Column(name = "s_name", nullable = true)
	protected String name;

	/**
	 * 字段别名
	 */
	@Column(name = "s_aliasName", nullable = true)
	protected String aliasName;

	/**
	 * 字段类型
	 */
	@Column(name = "s_datatype", nullable = true)
	protected String dataType;

	/**
	 * 是否是主键
	 */
	@Column(name = "b_key", nullable = true)
	protected Boolean key;
	
	/**
	 * 是否是自动增值列
	 */
	@Column(name = "b_auto", nullable = true)
	protected Boolean auto;
	
	/**
	 * 是否可以为空
	 */
	@Column(name = "b_allowNull", nullable = true)
	protected Boolean allowNull;

	/**
	 * 长度
	 */
	@Column(name = "i_maxlen", nullable = true)
	protected Integer maxlen;
	
	/**
	 * 小数位长度
	 */
	@Column(name = "d_decimaldigits", nullable = true)
	protected Double decimaldigits;
	
	/**
	 * 默认值
	 */
	@Column(name = "s_defaultValue", nullable = true)
	protected String defaultValue;

	/**
	 * 字典域
	 */
	@Column(name = "d_dictionaryname", nullable = true)
	protected String dictionaryName;

	public String getMid() {
		return mid;
	}

	public void setMid(String mid) {
		this.mid = mid;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAliasName() {
		return aliasName;
	}

	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public Boolean getKey() {
		return key;
	}

	public void setKey(Boolean isKey) {
		this.key = isKey;
	}

	public Boolean getAuto() {
		return auto;
	}

	public void setAuto(Boolean isAuto) {
		this.auto = isAuto;
	}

	public Boolean getAllowNull() {
		return allowNull;
	}

	public void setAllowNull(Boolean allowNull) {
		this.allowNull = allowNull;
	}

	public Integer getMaxlen() {
		return maxlen;
	}

	public void setMaxlen(Integer maxlen) {
		this.maxlen = maxlen;
	}

	public Double getDecimaldigits() {
		return decimaldigits;
	}

	public void setDecimaldigits(Double decimaldigits) {
		this.decimaldigits = decimaldigits;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getDictionaryName() {
		return dictionaryName;
	}

	public void setDictionaryName(String dictionaryName) {
		this.dictionaryName = dictionaryName;
	}

	@Override
	public MetadataEntity toEntity() {
		MetadataEntity toEntity = new MetadataEntity();
		BeanUtils.copyProperties(this, toEntity);
		return toEntity;
	}

	@Override
	public void from(MetadataEntity t) {
		BeanUtils.copyProperties(t, this);
	}
}
